package com.example.admin_test.common.controller;

import com.example.admin_test.emp.pojo.Dept;
import com.example.admin_test.emp.service.impl.EmpServiceImpl;
import com.example.admin_test.service.Impl.UserServiceImpl;
import com.wf.captcha.utils.CaptchaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class common_controller {
    @Autowired
    EmpServiceImpl empService;
    @GetMapping("/")
    public String print(){
        return "login";
    }
    @GetMapping("/index")
    public String index(){
        return "index";
    }
    @GetMapping("/welcome")
    public String welcome(){
        return "welcome";
    }
    @RequestMapping("/captcha")
    public void captcha(HttpServletRequest request, HttpServletResponse response) throws Exception {
        CaptchaUtil.out(request, response);
    }
    @GetMapping("/add/ui")
    public String empAdd(Model model){
        List<Dept> DeptList=empService.getAllDept();
        model.addAttribute("deptList",DeptList);
        System.out.println(DeptList);
        return "emp/empAdd";
    }

}
